export function formatUserPaginationData(data) {
  let res = []
  if (data === null || data === undefined) {
    return res
  }
  for (let i = 0; i < data.length; i++) {
    let now = data[i]
    res.push({
      id: now.id,
      imgUrl: now.imgUrl,
      phone: now.phone,
      nickname: now.nickname,
      qqEmail: now.qqEmail,
      sex: now.sex === 0 ? '女' : '男',
      disableStatus: now.disableStatus === 0 ? '正常' : '封禁',
      registerTime: now.gmtCreate
    })
  }
  return res
}

export function formatRoleTags(data) {
  let res = []
  for (let i = 0; i < data.length; i++) {
    let now = data[i]
    res.push({
      id: now.id,
      roleCode: now.roleCode,
      roleName: now.roleName,
    })
  }
  return res
}

export function formatRolePaginationData(data) {
  let res = []
  for (let i = 0; i < data.length; i++) {
    let now = data[i]
    res.push({
      id: now.id,
      roleName: now.roleName,
      roleCode: now.roleCode,
      description: now.description,
      createTime: now.gmtCreate
    })
  }
  return res
}

export function formatPermissionPaginationData(data) {
  let res = []
  for (let i = 0; i < data.length; i++) {
    let now = data[i]
    res.push({
      id: now.id,
      permissionName: now.permissionName,
      permissionCode: now.permissionCode,
      serverName: now.serverName,
      url: now.url,
      description: now.description,
      createTime: now.gmtCreate
    })
  }
  return res
}

export function formatPermissionPaginationDataWithCheck(data) {
  let res = []
  for (let i = 0; i < data.length; i++) {
    let now = data[i]
    res.push({
      id: now.id,
      permissionName: now.permissionName,
      permissionCode: now.permissionCode,
      serverName: now.serverName,
      url: now.url,
      description: now.description,
      hasPermission: now.hasPermission,
      createTime: now.gmtCreate
    })
  }
  return res
}

export function formatNoticePaginationData(data) {
  let res = []
  for (let i = 0; i < data.length; i++) {
    let now = data[i]
    res.push({
      id: now.id,
      userId: now.userId,
      title: now.title,
      content: now.content,
      createTime: now.gmtCreate
    })
  }
  return res
}

export function formatItemTypePaginationData(data) {
  let res = []
  for (let i = 0; i < data.length; i++) {
    let now = data[i]
    res.push({
      id: now.id,
      type: now.type,
      createTime: now.gmtCreate
    })
  }
  return res
}

export function formatFunctionPaginationData(data) {
  let res = []
  for (let i = 0; i < data.length; i++) {
    let now = data[i]
    res.push({
      id: now.id,
      functionName: now.functionName,
      functionCode: now.functionCode,
      description: now.description,
      createTime: now.gmtCreate
    })
  }
  return res
}
